﻿// MENU ---------------------------------------------------------------
$('.bb_border_mnu >li').hover(function () {
    var cmd = $(this);
    $('.bb_border_mnu li .bb_lnk_a span.icon_arround_left').remove();
    if (!cmd.children().hasClass('icon_arround_left')) {
        cmd.find('.bb_lnk_a').append('<span class="icon_arround_left"></span>');
    }
}, function () {
    $('.bb_border_mnu li .bb_lnk_a span.icon_arround_left').remove();
});

$('a.bb_lnk_a').hover(function (e) {
    var indexCurrent = $('a.bb_lnk_a').index($(this));
    if ((indexCurrent - 1) >= 0) {
        $('a.bb_lnk_a').eq(indexCurrent - 1).toggleClass('mr-pd');
    }
});

// CHECK IE 10 --------------------------------------------------------
if (navigator.userAgent.indexOf("MSIE 10") > -1) {
    $('a.bb_lnk_a').addClass('IE10_Padding');
    $('span.bb_all').addClass('IE10_pad_top_0');
    $('span.bb_p_m_txt3').addClass('IE10_pad_top_0');
}


// Show product list in cart --------------------------------------------------------------
$('#shopCartList').click(function () {
    $.ajax({
        url: '/Order/ShoppingCart',
        success: function (data) {
            $('.bb_wrap').append(data);
            $('.sp-wrap').fadeIn();
            $('.spc-icon-close, a.shopCartContinue').click(function () {
                $('.sp-wrap').fadeOut();
                $('.sp-wrap').remove();
            });
        },
        error: function () {
            Console.log('Đã có lỗi xảy ra!');
        }
    });
});

//show tab category 
function ShowTabCategory() {
    $('.tabCateHeader li').click(function () {
        $('.tabCateHeader li a').removeClass('tabCateHeader-ac');
        $('.tabCateHeader li a .drop-arrow').remove();
        $(this).children('a').addClass('tabCateHeader-ac');
        $(this).children('a').append('<span class="drop-arrow"></span>');
        var idx = $(this).index();
        $('.cateTabBody .toppromotion-body').hide();
        setTimeout(function() {
            $('.cateTabBody .toppromotion-body:eq(' + idx + ')').show();
        }, 350);
    });
}

//Category: hover OtherCategory

function OtherCateHover() {
    $('.CateOtherList li a').hover(function () {
        $('.CateOtherList li a span').remove();
        $(this).append('<span></span>');
    });
}


$('document').ready(function () {
    //Tab footer
    ShowTabNewsFooter();
    
    //show tab in category 
    ShowTabCategory();
    
    //hover other category
    OtherCateHover();

    //lazy load
    //lzLoading();
});
